<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.16"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>LibTools: H:/project/LibTools/src/file/File.cpp 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">LibTools
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.8.16 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','搜索');
});
/* @license-end */</script>
<div id="main-nav"></div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_f17c642dae9e225ab953fe9c6da2e34a.html">file</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">File.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_file_8cpp.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#include &lt;algorithm&gt;</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#include &lt;string.h&gt;</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_file_8h.html">File.h</a>&quot;</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &quot;../algorithm/Algorithm.h&quot;</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="preprocessor">#include &quot;../thread/SharedPtr.h&quot;</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#include &quot;../tools/ShareApi.h&quot;</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160; </div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<a class="code" href="tools_8h.html#a201ce692c9dca6599e5c12d00167419b">DEF_BEG_LIBTOOLS</a></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160; </div>
<div class="line"><a name="l00010"></a><span class="lineno"><a class="line" href="_file_8cpp.html#a6603d496276478a6816bd94c45823a5a">   10</a></span>&#160;<span class="preprocessor">#define LINEEND(ch) (ch == &#39;\r&#39; || ch == &#39;\n&#39;)</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160; </div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment">//static WIN32_FIND_DATAA g_cFileData;</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160; </div>
<div class="line"><a name="l00014"></a><span class="lineno"><a class="line" href="class_c_file.html#a82635098055a4778bdc7ec056066c19f">   14</a></span>&#160;<a class="code" href="class_c_file.html#a82635098055a4778bdc7ec056066c19f">CFile::CFile</a>()</div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;{</div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;     <a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a> = 0;</div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;    <span class="comment">//m_sError = NULL;</span></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;}</div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160; </div>
<div class="line"><a name="l00020"></a><span class="lineno"><a class="line" href="class_c_file.html#a146d61b38c752741357820a5f7e3f3b5">   20</a></span>&#160;<a class="code" href="class_c_file.html#a146d61b38c752741357820a5f7e3f3b5">CFile::~CFile</a>()</div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;{</div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;    <span class="comment">//if(_sError) {delete []m_sError; _sError = NULL;}</span></div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;    <span class="keywordflow">if</span>(<a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a>) </div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;    {</div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160;        <a class="code" href="namespace_share_api.html#a29fcdef9c215ce0009e28dd52ba2c853">ShareApi::CloseFile</a>(<a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a>);</div>
<div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;         <a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a> = 0;</div>
<div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;    }</div>
<div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;}</div>
<div class="line"><a name="l00029"></a><span class="lineno">   29</span>&#160; </div>
<div class="line"><a name="l00030"></a><span class="lineno"><a class="line" href="class_c_file.html#a81837734f4e121f9b2d619b9c2d7ab25">   30</a></span>&#160;<a class="code" href="class_c_file.html#a82635098055a4778bdc7ec056066c19f">CFile::CFile</a>(<span class="keyword">const</span> <a class="code" href="tools_8h.html#a65c91f8d7af3c67b8a21e089fdddd0fe">TCHAR</a>* sPath,<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> mode)</div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;{</div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;    <span class="comment">//m_sError = NULL;</span></div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;     <a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a> = 0;</div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;    <a class="code" href="class_c_file.html#a6ed7ee7c6dd3518dfbbb21e4640e4a8d">_Open</a>(sPath, mode);</div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;    <span class="comment">//if(!_Open(sPath,mode))</span></div>
<div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;    <span class="comment">//{     </span></div>
<div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;    <span class="comment">//  const TCHAR * sErr = File::GetLastError();</span></div>
<div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;    <span class="comment">//      throw sErr;</span></div>
<div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;    <span class="comment">//}</span></div>
<div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;}</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160; </div>
<div class="line"><a name="l00042"></a><span class="lineno"><a class="line" href="class_c_file.html#a50e268d58e7d90f6ba8448ea8e154211">   42</a></span>&#160;<span class="keywordtype">bool</span> <a class="code" href="class_c_file.html#a50e268d58e7d90f6ba8448ea8e154211">CFile::IsOpen</a>()<span class="keyword"> const</span></div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;<span class="keyword"></span>{</div>
<div class="line"><a name="l00044"></a><span class="lineno">   44</span>&#160;    <span class="keywordflow">return</span> (<a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a> == 0?<span class="keyword">false</span>:<span class="keyword">true</span>);</div>
<div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;}</div>
<div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160; </div>
<div class="line"><a name="l00047"></a><span class="lineno"><a class="line" href="class_c_file.html#abb45c1c269a23f09ac84a33ddf988647">   47</a></span>&#160;<span class="keywordtype">bool</span> <a class="code" href="class_c_file.html#abb45c1c269a23f09ac84a33ddf988647">CFile::Open</a>(<span class="keyword">const</span> <a class="code" href="tools_8h.html#a65c91f8d7af3c67b8a21e089fdddd0fe">TCHAR</a>* sPath,<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> mode)</div>
<div class="line"><a name="l00048"></a><span class="lineno">   48</span>&#160;{</div>
<div class="line"><a name="l00049"></a><span class="lineno">   49</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="class_c_file.html#a6ed7ee7c6dd3518dfbbb21e4640e4a8d">_Open</a>(sPath, mode);</div>
<div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;}</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160; </div>
<div class="line"><a name="l00052"></a><span class="lineno"><a class="line" href="class_c_file.html#a6ed7ee7c6dd3518dfbbb21e4640e4a8d">   52</a></span>&#160;<span class="keyword">inline</span> <span class="keywordtype">bool</span> <a class="code" href="class_c_file.html#a6ed7ee7c6dd3518dfbbb21e4640e4a8d">CFile::_Open</a>(<span class="keyword">const</span> <a class="code" href="tools_8h.html#a65c91f8d7af3c67b8a21e089fdddd0fe">TCHAR</a>* sPath, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> mode)</div>
<div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;{</div>
<div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;    <span class="keywordflow">return</span> (<a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a> = <a class="code" href="namespace_share_api.html#a8d8eb33de0a336b6c099d4196e75fbc6">ShareApi::OpenFile</a>(sPath, mode)) == 0 ? false : <span class="keyword">true</span>;</div>
<div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;}</div>
<div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160; </div>
<div class="line"><a name="l00057"></a><span class="lineno"><a class="line" href="class_c_file.html#a4b2c280dcb246eabe21eac127dc0c71d">   57</a></span>&#160;<a class="code" href="tools_8h.html#ae44d8d5d0e473c82cf8f2021a86cb6a4">fsize_t</a> <a class="code" href="class_c_file.html#a4b2c280dcb246eabe21eac127dc0c71d">CFile::Read</a>(<span class="keywordtype">void</span> *buf, <a class="code" href="tools_8h.html#ae44d8d5d0e473c82cf8f2021a86cb6a4">fsize_t</a> size)</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;{</div>
<div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;    <span class="keywordflow">if</span>(!<a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a>) <span class="keywordflow">return</span> -1;</div>
<div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160; </div>
<div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;    <span class="keywordflow">return</span> (<span class="keywordtype">int</span>)<a class="code" href="namespace_share_api.html#a4b481d0807997fab0917801a3203aad7">ShareApi::ReadFile</a>(<a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a>, buf, size);</div>
<div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;}</div>
<div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160; </div>
<div class="line"><a name="l00064"></a><span class="lineno"><a class="line" href="class_c_file.html#a68f6596c56190afd38fbe236ade81266">   64</a></span>&#160;<a class="code" href="tools_8h.html#ae44d8d5d0e473c82cf8f2021a86cb6a4">fsize_t</a> <a class="code" href="class_c_file.html#a68f6596c56190afd38fbe236ade81266">CFile::Write</a>(<span class="keyword">const</span> <span class="keywordtype">void</span> *buf, <a class="code" href="tools_8h.html#ae44d8d5d0e473c82cf8f2021a86cb6a4">fsize_t</a> size)</div>
<div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;{</div>
<div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;    <span class="keywordflow">if</span>(!<a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a>) <span class="keywordflow">return</span> -1;</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160; </div>
<div class="line"><a name="l00068"></a><span class="lineno">   68</span>&#160;    <span class="keywordflow">return</span> (<span class="keywordtype">int</span>)<a class="code" href="namespace_share_api.html#ad1a8ec9389fc2b1cbf9b7a2a10a054bd">ShareApi::WriteFile</a>(<a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a>, buf, size);</div>
<div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;}</div>
<div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160; </div>
<div class="line"><a name="l00071"></a><span class="lineno"><a class="line" href="class_c_file.html#a7430e2a509a825e6132fefc5d70a9867">   71</a></span>&#160;<span class="keywordtype">bool</span> <a class="code" href="class_c_file.html#a7430e2a509a825e6132fefc5d70a9867">CFile::Seek</a>(<a class="code" href="_file_8h.html#af08365f33add708e85b008961925f80e">bigint</a> offset,<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> origin)</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;{</div>
<div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;    <span class="keywordflow">if</span>(!<a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a>) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160; </div>
<div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="namespace_share_api.html#a52ea018b9be6f951d2bdce36cc0eae15">ShareApi::SetFilePointerEx</a>(<a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a>, offset, origin)?<span class="keyword">true</span>:<span class="keyword">false</span>;</div>
<div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;}</div>
<div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160; </div>
<div class="line"><a name="l00078"></a><span class="lineno"><a class="line" href="class_c_file.html#ad5d234b085d1aeea64c07b6a67409a64">   78</a></span>&#160;<a class="code" href="tools_8h.html#ae44d8d5d0e473c82cf8f2021a86cb6a4">fsize_t</a> <a class="code" href="class_c_file.html#ad5d234b085d1aeea64c07b6a67409a64">CFile::CurPos</a>()<span class="keyword"> const</span></div>
<div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;<span class="keyword"></span>{</div>
<div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;    <span class="keywordflow">if</span>(!<a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a>) <span class="keywordflow">return</span> -1;</div>
<div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160; </div>
<div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="namespace_share_api.html#acd17304851a877042934e8967d7ac27e">ShareApi::GetFilePointer</a>(<a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a>);</div>
<div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;}</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160; </div>
<div class="line"><a name="l00085"></a><span class="lineno"><a class="line" href="class_c_file.html#a811444b95b5723c677a74250ad919b77">   85</a></span>&#160;<a class="code" href="_file_8h.html#af08365f33add708e85b008961925f80e">bigint</a> <a class="code" href="class_c_file.html#a811444b95b5723c677a74250ad919b77">CFile::CurPosEx</a>()<span class="keyword"> const</span></div>
<div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;<span class="keyword"></span>{</div>
<div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;    <span class="keywordflow">if</span> (!<a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a>) <span class="keywordflow">return</span> -1;</div>
<div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160; </div>
<div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="namespace_share_api.html#a12d3c7f822d56a7161601bfde8cd2791">ShareApi::GetFilePointerEx</a>(<a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a>);</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;}</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160; </div>
<div class="line"><a name="l00092"></a><span class="lineno"><a class="line" href="class_c_file.html#a399f84f7d99f7888f11f740ce794e131">   92</a></span>&#160;<span class="keyword">const</span> <a class="code" href="tools_8h.html#a65c91f8d7af3c67b8a21e089fdddd0fe">TCHAR</a> *<a class="code" href="class_c_file.html#a399f84f7d99f7888f11f740ce794e131">CFile::GetLastError</a>()<span class="keyword"> const</span></div>
<div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;<span class="keyword"></span>{</div>
<div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;    <a class="code" href="class_shared_ptr.html">SharedPtr&lt;TCHAR&gt;</a> ec(<a class="code" href="namespace_share_api.html#a58553d013a36ffb0eb150b0eec157c63">ShareApi::Global_GetLastError</a>(), &amp;<a class="code" href="namespace_share_api.html#a79243d634ddf21dd7486ceb02e80e360">ShareApi::Global_FreeMem</a>);</div>
<div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;    <a class="code" href="tools_8h.html#a2c2000c5cd1b5ee50319176e11045bc4">tcscpy_safe</a>(const_cast&lt;CFile*&gt;(<span class="keyword">this</span>)-&gt;<a class="code" href="class_c_file.html#a3b0bd126af69300e37bf1ba58a8ca835">_errMsg</a>, <span class="keyword">sizeof</span>(<a class="code" href="class_c_file.html#a3b0bd126af69300e37bf1ba58a8ca835">_errMsg</a>), ec.<a class="code" href="class_shared_ptr.html#a0f15d2d3d2834b0667791f3abfd9e0d7">Get</a>());</div>
<div class="line"><a name="l00096"></a><span class="lineno">   96</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="class_c_file.html#a3b0bd126af69300e37bf1ba58a8ca835">_errMsg</a>;</div>
<div class="line"><a name="l00097"></a><span class="lineno">   97</span>&#160;}</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160; </div>
<div class="line"><a name="l00099"></a><span class="lineno"><a class="line" href="class_c_file.html#a3bb6d7223816bbdd132bbac81a5387bb">   99</a></span>&#160;<span class="keywordtype">bool</span> <a class="code" href="class_c_file.html#a3bb6d7223816bbdd132bbac81a5387bb">CFile::Eof</a>()<span class="keyword"> const</span></div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;<span class="keyword"></span>{</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;    <span class="keywordflow">if</span>(!<a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a>) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;    </div>
<div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;    <a class="code" href="_file_8h.html#af08365f33add708e85b008961925f80e">bigint</a> iPoint,iFileSize;</div>
<div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;    <span class="comment">// 获取文件大小</span></div>
<div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;    iFileSize = <a class="code" href="class_c_file.html#a0e1ef74f4c6c2e04b9577d208c2499e9">GetFileLength</a>();</div>
<div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;    <span class="comment">// 获取当前位置</span></div>
<div class="line"><a name="l00107"></a><span class="lineno">  107</span>&#160;    iPoint = <a class="code" href="class_c_file.html#ad5d234b085d1aeea64c07b6a67409a64">CurPos</a>();</div>
<div class="line"><a name="l00108"></a><span class="lineno">  108</span>&#160;    </div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;    <span class="keywordflow">if</span>(iFileSize == iPoint) <span class="keywordflow">return</span> <span class="keyword">true</span>;</div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">false</span>;</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160;}</div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160; </div>
<div class="line"><a name="l00113"></a><span class="lineno"><a class="line" href="class_c_file.html#aef44e989017afbcae77686b1a8e31993">  113</a></span>&#160;<a class="code" href="_file_8h.html#af08365f33add708e85b008961925f80e">bigint</a> <a class="code" href="class_c_file.html#aef44e989017afbcae77686b1a8e31993">CFile::GetFileLengthEx</a>()<span class="keyword"> const</span></div>
<div class="line"><a name="l00114"></a><span class="lineno">  114</span>&#160;<span class="keyword"></span>{</div>
<div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;    <span class="keywordflow">if</span>(!<a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a>) <span class="keywordflow">return</span> -1;</div>
<div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160; </div>
<div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="namespace_share_api.html#a5853aba96a6eaed3b9dd1a66805f6070">ShareApi::GetFileSizeEx</a>(<a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a>);</div>
<div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;}</div>
<div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160; </div>
<div class="line"><a name="l00120"></a><span class="lineno"><a class="line" href="class_c_file.html#a0e1ef74f4c6c2e04b9577d208c2499e9">  120</a></span>&#160;<a class="code" href="tools_8h.html#ae44d8d5d0e473c82cf8f2021a86cb6a4">fsize_t</a> <a class="code" href="class_c_file.html#a0e1ef74f4c6c2e04b9577d208c2499e9">CFile::GetFileLength</a>()<span class="keyword"> const</span></div>
<div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;<span class="keyword"></span>{</div>
<div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;    <span class="keywordflow">if</span> (!<a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a>) <span class="keywordflow">return</span> -1;</div>
<div class="line"><a name="l00123"></a><span class="lineno">  123</span>&#160; </div>
<div class="line"><a name="l00124"></a><span class="lineno">  124</span>&#160;    <span class="keywordflow">return</span> <a class="code" href="namespace_share_api.html#a8723a4c07d1482980a46b2f650bd2e5e">ShareApi::GetFileSize</a>(<a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a>);</div>
<div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;}</div>
<div class="line"><a name="l00126"></a><span class="lineno">  126</span>&#160; </div>
<div class="line"><a name="l00127"></a><span class="lineno"><a class="line" href="class_c_file.html#a8e3b6d9b96dfcd5e2205bc5a7ee85476">  127</a></span>&#160;<span class="keywordtype">void</span> <a class="code" href="class_c_file.html#a8e3b6d9b96dfcd5e2205bc5a7ee85476">CFile::Close</a>()</div>
<div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;{</div>
<div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;    <span class="keywordflow">if</span>(<a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a>){</div>
<div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;        <a class="code" href="namespace_share_api.html#a29fcdef9c215ce0009e28dd52ba2c853">ShareApi::CloseFile</a>(<a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a>);</div>
<div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;         <a class="code" href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">_hfDes</a> = 0;</div>
<div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;    }</div>
<div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;}</div>
<div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160; </div>
<div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;<a class="code" href="tools_8h.html#ac909db71799bb22cb7d636a34cd785e4">DEF_END_LIBTOOLS</a></div>
<div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160; </div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="aclass_c_file_html_a50e268d58e7d90f6ba8448ea8e154211"><div class="ttname"><a href="class_c_file.html#a50e268d58e7d90f6ba8448ea8e154211">CFile::IsOpen</a></div><div class="ttdeci">bool IsOpen() const</div><div class="ttdoc">判断文件是否打开</div><div class="ttdef"><b>Definition:</b> <a href="_file_8cpp_source.html#l00042">File.cpp:42</a></div></div>
<div class="ttc" id="aclass_c_file_html_a399f84f7d99f7888f11f740ce794e131"><div class="ttname"><a href="class_c_file.html#a399f84f7d99f7888f11f740ce794e131">CFile::GetLastError</a></div><div class="ttdeci">virtual const TCHAR * GetLastError() const</div><div class="ttdoc">返回上一次错误的信息</div><div class="ttdef"><b>Definition:</b> <a href="_file_8cpp_source.html#l00092">File.cpp:92</a></div></div>
<div class="ttc" id="anamespace_share_api_html_a29fcdef9c215ce0009e28dd52ba2c853"><div class="ttname"><a href="namespace_share_api.html#a29fcdef9c215ce0009e28dd52ba2c853">ShareApi::CloseFile</a></div><div class="ttdeci">LIBTOOLS void CloseFile(FILE_HANDLE hFile)</div><div class="ttdoc">关闭一个文件句柄</div><div class="ttdef"><b>Definition:</b> <a href="_share_api_8cpp_source.html#l00227">ShareApi.cpp:227</a></div></div>
<div class="ttc" id="atools_8h_html_a65c91f8d7af3c67b8a21e089fdddd0fe"><div class="ttname"><a href="tools_8h.html#a65c91f8d7af3c67b8a21e089fdddd0fe">TCHAR</a></div><div class="ttdeci">#define TCHAR</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00187">tools.h:187</a></div></div>
<div class="ttc" id="a_file_8h_html"><div class="ttname"><a href="_file_8h.html">File.h</a></div></div>
<div class="ttc" id="aclass_c_file_html_a4b2c280dcb246eabe21eac127dc0c71d"><div class="ttname"><a href="class_c_file.html#a4b2c280dcb246eabe21eac127dc0c71d">CFile::Read</a></div><div class="ttdeci">virtual fsize_t Read(void *buf, fsize_t size)</div><div class="ttdoc">读取文件，</div><div class="ttdef"><b>Definition:</b> <a href="_file_8cpp_source.html#l00057">File.cpp:57</a></div></div>
<div class="ttc" id="aclass_c_file_html_a3b0bd126af69300e37bf1ba58a8ca835"><div class="ttname"><a href="class_c_file.html#a3b0bd126af69300e37bf1ba58a8ca835">CFile::_errMsg</a></div><div class="ttdeci">TCHAR _errMsg[MAX_PATH]</div><div class="ttdef"><b>Definition:</b> <a href="_file_8h_source.html#l00128">File.h:128</a></div></div>
<div class="ttc" id="aclass_shared_ptr_html"><div class="ttname"><a href="class_shared_ptr.html">SharedPtr</a></div><div class="ttdoc">智能指针</div><div class="ttdef"><b>Definition:</b> <a href="_shared_ptr_8h_source.html#l00119">SharedPtr.h:119</a></div></div>
<div class="ttc" id="aclass_shared_ptr_html_a0f15d2d3d2834b0667791f3abfd9e0d7"><div class="ttname"><a href="class_shared_ptr.html#a0f15d2d3d2834b0667791f3abfd9e0d7">SharedPtr::Get</a></div><div class="ttdeci">Ty * Get()</div><div class="ttdef"><b>Definition:</b> <a href="_shared_ptr_8h_source.html#l00202">SharedPtr.h:202</a></div></div>
<div class="ttc" id="aclass_c_file_html_a3bb6d7223816bbdd132bbac81a5387bb"><div class="ttname"><a href="class_c_file.html#a3bb6d7223816bbdd132bbac81a5387bb">CFile::Eof</a></div><div class="ttdeci">virtual bool Eof() const</div><div class="ttdoc">判断是否到达文件尾</div><div class="ttdef"><b>Definition:</b> <a href="_file_8cpp_source.html#l00099">File.cpp:99</a></div></div>
<div class="ttc" id="atools_8h_html_a201ce692c9dca6599e5c12d00167419b"><div class="ttname"><a href="tools_8h.html#a201ce692c9dca6599e5c12d00167419b">DEF_BEG_LIBTOOLS</a></div><div class="ttdeci">#define DEF_BEG_LIBTOOLS</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00036">tools.h:36</a></div></div>
<div class="ttc" id="anamespace_share_api_html_a4b481d0807997fab0917801a3203aad7"><div class="ttname"><a href="namespace_share_api.html#a4b481d0807997fab0917801a3203aad7">ShareApi::ReadFile</a></div><div class="ttdeci">LIBTOOLS fsize_t ReadFile(FILE_HANDLE hFile, void *buf, fsize_t size)</div><div class="ttdoc">读取文件数据</div><div class="ttdef"><b>Definition:</b> <a href="_share_api_8cpp_source.html#l00236">ShareApi.cpp:236</a></div></div>
<div class="ttc" id="aclass_c_file_html_a6ed7ee7c6dd3518dfbbb21e4640e4a8d"><div class="ttname"><a href="class_c_file.html#a6ed7ee7c6dd3518dfbbb21e4640e4a8d">CFile::_Open</a></div><div class="ttdeci">bool _Open(const TCHAR *sPath, unsigned int mode)</div><div class="ttdef"><b>Definition:</b> <a href="_file_8cpp_source.html#l00052">File.cpp:52</a></div></div>
<div class="ttc" id="aclass_c_file_html_a0e1ef74f4c6c2e04b9577d208c2499e9"><div class="ttname"><a href="class_c_file.html#a0e1ef74f4c6c2e04b9577d208c2499e9">CFile::GetFileLength</a></div><div class="ttdeci">fsize_t GetFileLength() const</div><div class="ttdef"><b>Definition:</b> <a href="_file_8cpp_source.html#l00120">File.cpp:120</a></div></div>
<div class="ttc" id="atools_8h_html_a2c2000c5cd1b5ee50319176e11045bc4"><div class="ttname"><a href="tools_8h.html#a2c2000c5cd1b5ee50319176e11045bc4">tcscpy_safe</a></div><div class="ttdeci">#define tcscpy_safe</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00199">tools.h:199</a></div></div>
<div class="ttc" id="anamespace_share_api_html_a8723a4c07d1482980a46b2f650bd2e5e"><div class="ttname"><a href="namespace_share_api.html#a8723a4c07d1482980a46b2f650bd2e5e">ShareApi::GetFileSize</a></div><div class="ttdeci">LIBTOOLS int GetFileSize(FILE_HANDLE hFile)</div><div class="ttdoc">参考GetFileSizeEx的说明</div><div class="ttdef"><b>Definition:</b> <a href="_share_api_8cpp_source.html#l00159">ShareApi.cpp:159</a></div></div>
<div class="ttc" id="anamespace_share_api_html_a52ea018b9be6f951d2bdce36cc0eae15"><div class="ttname"><a href="namespace_share_api.html#a52ea018b9be6f951d2bdce36cc0eae15">ShareApi::SetFilePointerEx</a></div><div class="ttdeci">LIBTOOLS BOOL SetFilePointerEx(FILE_HANDLE hFile, INT64 dwOffset, int iWhence)</div><div class="ttdoc">定位文件指针</div><div class="ttdef"><b>Definition:</b> <a href="_share_api_8cpp_source.html#l00174">ShareApi.cpp:174</a></div></div>
<div class="ttc" id="aclass_c_file_html_a7430e2a509a825e6132fefc5d70a9867"><div class="ttname"><a href="class_c_file.html#a7430e2a509a825e6132fefc5d70a9867">CFile::Seek</a></div><div class="ttdeci">virtual bool Seek(bigint offset, unsigned int origin)</div><div class="ttdoc">设置文件指针位置</div><div class="ttdef"><b>Definition:</b> <a href="_file_8cpp_source.html#l00071">File.cpp:71</a></div></div>
<div class="ttc" id="atools_8h_html_ac909db71799bb22cb7d636a34cd785e4"><div class="ttname"><a href="tools_8h.html#ac909db71799bb22cb7d636a34cd785e4">DEF_END_LIBTOOLS</a></div><div class="ttdeci">#define DEF_END_LIBTOOLS</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00038">tools.h:38</a></div></div>
<div class="ttc" id="anamespace_share_api_html_a58553d013a36ffb0eb150b0eec157c63"><div class="ttname"><a href="namespace_share_api.html#a58553d013a36ffb0eb150b0eec157c63">ShareApi::Global_GetLastError</a></div><div class="ttdeci">LIBTOOLS TCHAR * Global_GetLastError(DWORD *pError=NULL)</div><div class="ttdoc">获取错误信息</div><div class="ttdef"><b>Definition:</b> <a href="_share_api_8cpp_source.html#l00508">ShareApi.cpp:508</a></div></div>
<div class="ttc" id="anamespace_share_api_html_acd17304851a877042934e8967d7ac27e"><div class="ttname"><a href="namespace_share_api.html#acd17304851a877042934e8967d7ac27e">ShareApi::GetFilePointer</a></div><div class="ttdeci">LIBTOOLS int GetFilePointer(FILE_HANDLE hFile)</div><div class="ttdoc">参考GetFilePointerEx的函数说明</div><div class="ttdef"><b>Definition:</b> <a href="_share_api_8cpp_source.html#l00214">ShareApi.cpp:214</a></div></div>
<div class="ttc" id="aclass_c_file_html_abbe85e6c0121d504aff029c7c7786719"><div class="ttname"><a href="class_c_file.html#abbe85e6c0121d504aff029c7c7786719">CFile::_hfDes</a></div><div class="ttdeci">FILE_HANDLE _hfDes</div><div class="ttdef"><b>Definition:</b> <a href="_file_8h_source.html#l00127">File.h:127</a></div></div>
<div class="ttc" id="atools_8h_html_ae44d8d5d0e473c82cf8f2021a86cb6a4"><div class="ttname"><a href="tools_8h.html#ae44d8d5d0e473c82cf8f2021a86cb6a4">fsize_t</a></div><div class="ttdeci">INTPTR_T fsize_t</div><div class="ttdef"><b>Definition:</b> <a href="tools_8h_source.html#l00237">tools.h:237</a></div></div>
<div class="ttc" id="anamespace_share_api_html_ad1a8ec9389fc2b1cbf9b7a2a10a054bd"><div class="ttname"><a href="namespace_share_api.html#ad1a8ec9389fc2b1cbf9b7a2a10a054bd">ShareApi::WriteFile</a></div><div class="ttdeci">LIBTOOLS fsize_t WriteFile(FILE_HANDLE hFile, const void *buf, fsize_t size)</div><div class="ttdoc">向文件中写入数据</div><div class="ttdef"><b>Definition:</b> <a href="_share_api_8cpp_source.html#l00251">ShareApi.cpp:251</a></div></div>
<div class="ttc" id="aclass_c_file_html_a82635098055a4778bdc7ec056066c19f"><div class="ttname"><a href="class_c_file.html#a82635098055a4778bdc7ec056066c19f">CFile::CFile</a></div><div class="ttdeci">CFile()</div><div class="ttdef"><b>Definition:</b> <a href="_file_8cpp_source.html#l00014">File.cpp:14</a></div></div>
<div class="ttc" id="aclass_c_file_html_a811444b95b5723c677a74250ad919b77"><div class="ttname"><a href="class_c_file.html#a811444b95b5723c677a74250ad919b77">CFile::CurPosEx</a></div><div class="ttdeci">virtual bigint CurPosEx() const</div><div class="ttdoc">获取文件当前指针位置,失败返回-1，成功返回文件当前的指针位置</div><div class="ttdef"><b>Definition:</b> <a href="_file_8cpp_source.html#l00085">File.cpp:85</a></div></div>
<div class="ttc" id="aclass_c_file_html_a68f6596c56190afd38fbe236ade81266"><div class="ttname"><a href="class_c_file.html#a68f6596c56190afd38fbe236ade81266">CFile::Write</a></div><div class="ttdeci">virtual fsize_t Write(const void *buf, fsize_t size)</div><div class="ttdoc">写入数据到文件中</div><div class="ttdef"><b>Definition:</b> <a href="_file_8cpp_source.html#l00064">File.cpp:64</a></div></div>
<div class="ttc" id="anamespace_share_api_html_a79243d634ddf21dd7486ceb02e80e360"><div class="ttname"><a href="namespace_share_api.html#a79243d634ddf21dd7486ceb02e80e360">ShareApi::Global_FreeMem</a></div><div class="ttdeci">LIBTOOLS void Global_FreeMem(TCHAR *sInfo)</div><div class="ttdoc">释放由Global_GetLastErrr函数申请的内存</div><div class="ttdef"><b>Definition:</b> <a href="_share_api_8cpp_source.html#l00542">ShareApi.cpp:542</a></div></div>
<div class="ttc" id="a_file_8h_html_af08365f33add708e85b008961925f80e"><div class="ttname"><a href="_file_8h.html#af08365f33add708e85b008961925f80e">bigint</a></div><div class="ttdeci">UINT64 bigint</div><div class="ttdef"><b>Definition:</b> <a href="_file_8h_source.html#l00007">File.h:7</a></div></div>
<div class="ttc" id="aclass_c_file_html_a146d61b38c752741357820a5f7e3f3b5"><div class="ttname"><a href="class_c_file.html#a146d61b38c752741357820a5f7e3f3b5">CFile::~CFile</a></div><div class="ttdeci">virtual ~CFile()</div><div class="ttdef"><b>Definition:</b> <a href="_file_8cpp_source.html#l00020">File.cpp:20</a></div></div>
<div class="ttc" id="anamespace_share_api_html_a12d3c7f822d56a7161601bfde8cd2791"><div class="ttname"><a href="namespace_share_api.html#a12d3c7f822d56a7161601bfde8cd2791">ShareApi::GetFilePointerEx</a></div><div class="ttdeci">LIBTOOLS INT64 GetFilePointerEx(FILE_HANDLE hFile)</div><div class="ttdoc">返回当前文件指针位置</div><div class="ttdef"><b>Definition:</b> <a href="_share_api_8cpp_source.html#l00202">ShareApi.cpp:202</a></div></div>
<div class="ttc" id="aclass_c_file_html_abb45c1c269a23f09ac84a33ddf988647"><div class="ttname"><a href="class_c_file.html#abb45c1c269a23f09ac84a33ddf988647">CFile::Open</a></div><div class="ttdeci">virtual bool Open(const TCHAR *sPath, unsigned int mode)</div><div class="ttdoc">打开文件</div><div class="ttdef"><b>Definition:</b> <a href="_file_8cpp_source.html#l00047">File.cpp:47</a></div></div>
<div class="ttc" id="anamespace_share_api_html_a8d8eb33de0a336b6c099d4196e75fbc6"><div class="ttname"><a href="namespace_share_api.html#a8d8eb33de0a336b6c099d4196e75fbc6">ShareApi::OpenFile</a></div><div class="ttdeci">LIBTOOLS FILE_HANDLE OpenFile(const TCHAR *szFileName, unsigned int iMode)</div><div class="ttdoc">打开文件</div><div class="ttdef"><b>Definition:</b> <a href="_share_api_8cpp_source.html#l00084">ShareApi.cpp:84</a></div></div>
<div class="ttc" id="aclass_c_file_html_a8e3b6d9b96dfcd5e2205bc5a7ee85476"><div class="ttname"><a href="class_c_file.html#a8e3b6d9b96dfcd5e2205bc5a7ee85476">CFile::Close</a></div><div class="ttdeci">virtual void Close()</div><div class="ttdoc">关闭文件</div><div class="ttdef"><b>Definition:</b> <a href="_file_8cpp_source.html#l00127">File.cpp:127</a></div></div>
<div class="ttc" id="anamespace_share_api_html_a5853aba96a6eaed3b9dd1a66805f6070"><div class="ttname"><a href="namespace_share_api.html#a5853aba96a6eaed3b9dd1a66805f6070">ShareApi::GetFileSizeEx</a></div><div class="ttdeci">LIBTOOLS INT64 GetFileSizeEx(FILE_HANDLE hFile)</div><div class="ttdoc">获取文件大小</div><div class="ttdef"><b>Definition:</b> <a href="_share_api_8cpp_source.html#l00146">ShareApi.cpp:146</a></div></div>
<div class="ttc" id="aclass_c_file_html_ad5d234b085d1aeea64c07b6a67409a64"><div class="ttname"><a href="class_c_file.html#ad5d234b085d1aeea64c07b6a67409a64">CFile::CurPos</a></div><div class="ttdeci">virtual fsize_t CurPos() const</div><div class="ttdef"><b>Definition:</b> <a href="_file_8cpp_source.html#l00078">File.cpp:78</a></div></div>
<div class="ttc" id="aclass_c_file_html_aef44e989017afbcae77686b1a8e31993"><div class="ttname"><a href="class_c_file.html#aef44e989017afbcae77686b1a8e31993">CFile::GetFileLengthEx</a></div><div class="ttdeci">bigint GetFileLengthEx() const</div><div class="ttdef"><b>Definition:</b> <a href="_file_8cpp_source.html#l00113">File.cpp:113</a></div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者 &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.16
</small></address>
</body>
</html>
